import java.lang.reflect.InvocationTargetException;

public class OperationFactory {
    public static Operation create(String name) throws Exception {
        try {
            return (Operation)Class.forName("Operation"+name).getConstructor().newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            throw new ClassCastException("没有这种操作");
        }
        return null;
    }
}
